import sys,time
import os


# if os.getenv('AG_ENV_PYTHON_PATH') is None:
#     ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) + os.sep
# else:
#     ROOT_DIR = os.getcwd() + os.sep
#     # ROOT_DIR = WORK_DIR + "ag_art" + os.sep
# parent_dir = os.path.dirname(ROOT_DIR)
# import importlib.util
# tuijianjob_path = parent_dir+'/TuijianJob.py'
# spec = importlib.util.spec_from_file_location('TuijianJob', tuijianjob_path)
# tuijianjob_module = importlib.util.module_from_spec(spec)
# spec.loader.exec_module(tuijianjob_module)
# TuijianJob = tuijianjob_module.TuijianJob
from TuijianJob import TuijianJob

def main(tmpl_no, cog_dest):

    try:
        tmpl_no = tmpl_no
        cog_dest = cog_dest
        success_tmp = True
        msg = ''
        timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    except Exception as e:
        success_tmp = False
        msg = f'invalid_parameter_type--{str(e)}'
        timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    if success_tmp:
        # try:
        #     message = TuijianJob(p_tmpl_no=tmpl_no, p_cog_dest=cog_dest).execute()
        #     timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
        #     success_tmp = True
        #     msg = message
        # except Exception as e:
        #     success_tmp = False
        #     msg = f'run_model_job_failed---with--{str(e)}'
        #     timestamp = None
        message = TuijianJob(p_tmpl_no=tmpl_no, p_cog_dest=cog_dest).execute()
        timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
        success_tmp = True
        msg = message
    success = success_tmp
    message = msg
    timestamp = timestamp
    return success, message, timestamp
if __name__ == '__main__':
    success, message, timestamp = main(tmpl_no='202309_01', cog_dest='发电')
    print(success, message, timestamp)
